/* ScrollPane is a widget which can be scrolled up and down like a KineticListBox, but without selecting items */
#ifndef SCROLLPANE_H_
#define SCROLLPANE_H_

#include <MAUI/Layout.h>
#include <MAUtil/Environment.h>

using namespace MAUI;
using namespace MAUtil;

#define FRAMES 1000
#define FPS 50
#define MS_PER_FRAME (1000/FPS)
#define DURATION 250
#define HISTORY_LENGTH 10 // The amount of mouse move events to keep track of

class ScrollPane : public Layout, public TimerListener
{
	public:
		ScrollPane(int x, int y, int width, int height, Widget* parent = NULL, int rows = 2, int cols = 2);
		~ScrollPane();

		//TimerListener
		void runTimerEvent();

		//Standard widget items
		void draw(bool forceDraw = false);
		void setEnabled(bool enabled = true);
		void setSelected(bool selected = true);

		/*//PointerListener
		void pointerPressEvent(MAPoint2d point);
		void pointerReleaseEvent(MAPoint2d point);
		void pointerMoveEvent(MAPoint2d point);*/

		//Non-touch screen support
		void scrollUp(int pixels = 15);
		void scrollDown(int pixels = 15);

        /** Returns true if child widgets is outside of the front of the list. */
        bool listFrontOutsideBounds();

        /** Returns true if child widgets is outside of the back of the list. */
        bool listBackOutsideBounds();

        //Resets the scroll pane to a zero offset
        void reset();
	private:
        int yOffsetFrom;
        int yOffsetTo;
        int yOffset;
        int yOffsetInc;
        int animTimeStart;
        bool kineticTimer;
        bool enabled;
        bool listening;

        Point velocity;
        Vector<Point> previousPoints;
        Vector<float> previousTimes;

        void stop();
};

#endif //SCROLLPANE_H_
